<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text"> <button>点击</button>
    <div></div>
    <script>
        var str = '     213    ';
        console.log(str);
        console.log(str.trim());
        var input = document.querySelector('input');
        var btn = document.querySelector('button');
        var div = document.querySelector('div');
        btn.onclick = function() {
            if (input.value.trim() === '') {
                alert("请输入内容");
            } else {
                div.innerHTML = input.value;
            }
        }
    </script>
</body>

</html>